<template>
	<div id="app">
		<!-- 登录 -->
		<login v-if="!isLogin" @setLogin="setLogin"></login>
		<!-- 管理主页 -->
		<my-frame v-if="isLogin" :isRouterAlive="isRouterAlive"></my-frame>
	</div>
</template>

<script>
import Login from "pc/login/Login"
import MyFrame from "pc/frame/Frame"

export default {
	provide () {
		return {
			reload: this.reload
		}
	},
	data(){
		return {
			isLogin: this.$cookie.get('isLogin'), //是否登录
			isRouterAlive: true
		}
	},
	created: function() {
		/*刚登陆进来，判断是否有默认选择菜单，如果没有跳转到console组件*/
		let currMenuID = this.$localstorage.get('currMenuID');
		if(currMenuID == null){
			this.$router.push({ name: 'console'})
		}
	},
	methods: {
		/*改变登录状态*/
		setLogin(res){
			this.isLogin = res
		},
		reload () {
			this.isLogin = this.$cookie.get('isLogin') //是否登录
			this.isRouterAlive = false;
			this.$nextTick(function () {
				this.isRouterAlive = true
			});
		}
	},
	components: {
		Login,
		MyFrame
	},
}
</script>

<style lang="stylus" scoped>
	#app
		height: 100%
</style>
